/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package smary.ejb.entity;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlRootElement;

/**
 * Die STATUSAENDEUNG Entität speichert alle Statusaenderungen die an Tasks
 * vorgenommen wurden. Sie funktioniert in der selben Art und Weise wie eine
 * Logfile.
 * @author Alex
 */
@Entity
@Table(name = "STATUSAENDERUNG")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Statusaenderung.findAll", query = "SELECT s FROM Statusaenderung s"),
    @NamedQuery(name = "Statusaenderung.findByTaskaenderungid", query = "SELECT s FROM Statusaenderung s WHERE s.taskaenderungid = :taskaenderungid"),
    @NamedQuery(name = "Statusaenderung.findByTask", query = "SELECT s FROM Statusaenderung s WHERE s.task = :task"),
    @NamedQuery(name = "Statusaenderung.findByStatus", query = "SELECT s FROM Statusaenderung s WHERE s.status = :status"),
    @NamedQuery(name = "Statusaenderung.findByDatum", query = "SELECT s FROM Statusaenderung s WHERE s.datum = :datum")})
public class Statusaenderung implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "TASKAENDERUNGID")
    @GeneratedValue(strategy= GenerationType.AUTO)
    private Integer taskaenderungid;
//    @Basic(optional = false)
//    @NotNull
//    @Column(name = "TASKID")
//    private int taskid;
//    @Basic(optional = false)
//    @NotNull
//    @Column(name = "STATUSID")
//    private int statusid;
    @Basic(optional = false)
    @NotNull
    @Column(name = "DATUM")
    @Temporal(TemporalType.DATE)
    private Date datum;

    @ManyToOne
    @JoinColumn(name="TASKID",referencedColumnName="TASKID")
    protected Task task;
    
    @ManyToOne
    @JoinColumn(name="STATUSID",referencedColumnName="STATUSID")
    protected Status status;

    public Status getStatus() {
        return status;
    }

    public void setStatus(Status status) {
        this.status = status;
    }

    public Task getTask() {
        return task;
    }

    public void setTask(Task task) {
        this.task = task;
    }
    
    public Statusaenderung() {
    }

    public Statusaenderung(Integer taskaenderungid) {
        this.taskaenderungid = taskaenderungid;
    }

    public Statusaenderung(Integer taskaenderungid, Task taskid, Status statusid, Date datum) {
        this.taskaenderungid = taskaenderungid;
        this.task = taskid;
        this.status = statusid;
        this.datum = datum;
    }

    public Integer getTaskaenderungid() {
        return taskaenderungid;
    }

    public void setTaskaenderungid(Integer taskaenderungid) {
        this.taskaenderungid = taskaenderungid;
    }
    public Date getDatum() {
        return datum;
    }

    public void setDatum(Date datum) {
        this.datum = datum;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (taskaenderungid != null ? taskaenderungid.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Statusaenderung)) {
            return false;
        }
        Statusaenderung other = (Statusaenderung) object;
        if ((this.taskaenderungid == null && other.taskaenderungid != null) || (this.taskaenderungid != null && !this.taskaenderungid.equals(other.taskaenderungid))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "smary.ejb.Statusaenderung[ taskaenderungid=" + taskaenderungid + " ]";
    }
    
}
